home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / Miro_Installer.exe / Miro_Downloader.exe / license.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-01-10  |  1.5 KB  |  36 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. '''Support for licensing in Miro-consumed feeds.'''
  5. from gtcache import gettext as _
  6. import rdfa
  7. DC_TITLE = 'http://purl.org/dc/elements/1.1/title'
  8.  
  9. class DictSink(object):
  10.     '''Simple sink for the RDFa parser; stores triples in a nested dict
  11.     structure.  After parsing self[subject][predicate] contains a list 
  12.     of objects.'''
  13.     
  14.     def __init__(self):
  15.         self.data = { }
  16.  
  17.     
  18.     def triple(self, s, p, o):
  19.         self.data.setdefault(s, { }).setdefault(p, []).append(o)
  20.  
  21.  
  22.  
  23. def license_name(license_uri):
  24.     '''Attempt to determine the license name from the URI; if the name cannot
  25.     be determined, the URI is returned unchanged.'''
  26.     
  27.     try:
  28.         sink = rdfa.parseURI(license_uri, sink = DictSink())
  29.         license_name = sink.data.get(license_uri, sink.data[u''])[DC_TITLE][0].strip()
  30.         return license_name[1:license_name.find('"', 1)]
  31.     except (IOError, KeyError):
  32.         e = None
  33.         return _('license page')
  34.  
  35.  
  36.